package com.limao.CacheManager;

import com.Hazelcast.Cache;
import com.Hazelcast.CacheFactory;
import com.limao.DBDataClass.RMB_WithdrawDataClass;
import com.limao.DBProvider.RMB_WithdrawProvider;
import com.limao.Model.LzPluginException;
import com.limao.Model.PublicData;
import com.limao.cache.BasicModule;

public class RmbwithdrawCacheManager  extends BasicModule{

	private RMB_WithdrawProvider provider;
	private static RmbwithdrawCacheManager instance;

	public static RmbwithdrawCacheManager getInstance() {
		return instance;
	}

	private Cache<String, RMB_WithdrawDataClass> RMB_WithdrawCache;

	public RmbwithdrawCacheManager() {
    	super("RmbwithdrawCacheManager");
    	RMB_WithdrawCache = CacheFactory.createCache("cd_rmbwithdrawCache");
		initProvider();

	}

    
    @Override
	public void initialize() {
        super.initialize();
        instance=this;
    }
    
    public void ClearObjectCache(String withdrawid)
    {
    	RMB_WithdrawDataClass tmp = RMB_WithdrawCache.get(withdrawid);
    	if(tmp!=null)
    		RMB_WithdrawCache.remove(tmp.withdrawid);

    } 
  
	//&新鲜宝   增加提现单
	public boolean Add_WithdrawOrder(int userid,float rmb,float maxRmb)	throws LzPluginException {
		
		return provider.WithdrawAdd_Order(userid,rmb,maxRmb);

	}

	
	//&新鲜宝  查某人提现列表
	public PublicData load_WithdrawOrderList(int userid, int curpage,long sarttime,long endtime) throws LzPluginException {
		
		return provider.load_WithdrawOrderList(userid, curpage,sarttime,endtime);

	}	
		
	//&新鲜宝  查某人某单提现详情
	public RMB_WithdrawDataClass load_WithdrawById(int withdrawid) throws LzPluginException {
		
		RMB_WithdrawDataClass obj=RMB_WithdrawCache.get(withdrawid+"");
		if(obj==null)
		{
			obj = provider.load_WithdrawById(withdrawid);
			if (obj != null) {
				RMB_WithdrawCache.put(obj.withdrawid, obj);
			}
		}
		return obj;
	}	
	
	public boolean load_WithdrawByIdNum(int id) throws LzPluginException {
		return provider.load_WithdrawByIdNum(id);
	}	
	
	
	

	
	
	
	private void initProvider() {
		if (provider == null) {
			try {
				provider = RMB_WithdrawProvider.getInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	
}
